home *** CD-ROM | disk | FTP | other *** search
/ C# & Game Programming - A…er's Guide (2nd Edition) / Buono 2nd Ed.iso / Chapter2 / 2.6 / 2.6.cs next >
Encoding:
Text File  |  2004-08-31  |  766 b   |  26 lines

  1. /* The else-if statement as a dependent statement. */
  2. using System;
  3.  
  4. namespace Chapter2 {
  5.     class Class1 {
  6.         static void Main() {
  7.             string input;
  8.             double Answer;  
  9.  
  10.             Console.Write ("1 + 1.5 =  ");   
  11.             input = Console.ReadLine ();   
  12.             Answer = double.Parse (input);
  13.            
  14.             if (Answer == 2.5)      
  15.                 Console.WriteLine ("\n That is correct!");   
  16.             else if (Answer > 2.5)    
  17.                 Console.WriteLine ("\n Wrong, too high!!!"); 
  18.             else            
  19.                 Console.WriteLine ("\n Wrong, too low!!!");                                
  20.  
  21.             Console.WriteLine ("I hate the if statement!");
  22.         }
  23.     }
  24. }
  25.  
  26.